/*
 * util.c
 *
 *  Created on: Sep 30, 2014
 *      Author: amorim
 */

#include <stdlib.h>
#include <stdio.h>
#include <string>
#include "util.h"
#include "unistd.h"

void sleep(int i) {
	int c = 1;
	for (c = 1; c <= i * 10; c++)
		msleep(100);
}
void msleep(int i) {
	int c = 1;

	for (c = 1; c <= i * 10; c++)
		usleep(100);
}
int checksum(int len, char * dat) {
	int cksm;
	int i;

	cksm = 0;
	for (i = 0; i < len; i++)
		cksm ^= dat[i];

	return cksm;
}
void printBuf(char * buf, int bufLen) {
	int i;

	for (i = 0; i < bufLen; i++) {
		if (isprint(buf[i]))
			printf("%c ", buf[i]);
		else
			printf("%02X ", buf[i]);
	}

	printf("\n");
}
